import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import CourseStore from './module/course'
import VideoStore from './module/video'
export default new Vuex.Store({
    state: {
        defAct: "首页", //默认激活的导航
        adminDia: false, //管理员页面的弹出层
        breadData: localStorage.breadData ? JSON.parse(localStorage.breadData) : [], //面包屑导航的数据
        menuColl: true, //菜单折叠
        navFlag: true, //导航栏显示隐藏
        userInfo: localStorage.userInfo ? JSON.parse(localStorage.userInfo) : {}
    },
    mutations: {
        changedefAct(state, name) { //改变当前默认导航
            state.defAct = name;
            console.log(state.defAct)
        },
        changeFlag(state, flag) {
            state.navFlag = flag;
        },
        changeUser(state, info) { //修改用户信息的state
            state.userInfo = info;
        },
        changeMenu(state, flag) {
            state.menuColl = flag;
        },
        changeData(state, arr) { //改变面包屑导航的数据
            console.log(arr)
            state.breadData = arr;
            localStorage.breadData = JSON.stringify(arr)
        },
        changeAdminDia(state, flag) {
            state.adminDia = flag;
        }
    },
    actions: {},
    modules: {
        CourseStore,
        VideoStore
    }
})